import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/5/6
 * Time:17:47
 **/
public class Main2 {
    /**
     * 每日一题-两种排序方法
     *
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {
        //BufferedReader从字符流中读取文本并缓存
        BufferedReader bi = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(bi.readLine());
        String[] str = new String[n];
        for (int i = 0; i < n; i++) {
            str[i] = bi.readLine();
        }
        //判断排序方式
        if (isLexicographically(str) && isLengths(str)) {
            System.out.println("both");
        } else if (isLexicographically(str)) {
            System.out.println("lexicographically");
        } else if (isLengths(str)) {
            System.out.println("lengths");
        } else {
            System.out.println("none");
        }
    }

    public static boolean isLexicographically(String[] str) {
        for (int i = 0; i < str.length - 1; i++) {
            //用当前字符串和后一个比较，如果字典序大于后一个，说明不是这样排序的
            if (str[i].compareTo(str[i + 1]) > 0) {
                return false;
            }
        }
        return true;
    }

    public static boolean isLengths(String[] str) {
        for (int i = 0; i < str.length - 1; i++) {
            //判断当前长度大于后一个字符串的长度,如果长度大于后一个，说明不是这样排序的
            if (str[i].length() > str[i + 1].length()) {
                return false;
            }
        }
        return true;
    }
}
